package com.gm.nanopct3.tools;

import com.gm.hardwarelib.pin.NanopcT3GPIO;

/**
 * Created by Mouse on 2017/8/19.
 */

public enum Freq {

    CL1(261.6255653, "CL1"),
    CL2(293.6647679, "CL2"),
    CL3(329.6275569, "CL3"),
    CL4(349.2282314, "CL4"),
    CL5(391.995436, "CL5"),
    CL6(440, "CL6"),
    CL7(493.8833013, "CL7"),
    CM1(523.2511306, "CM1"),
    CM2(587.3295358, "CM2"),
    CM3(659.2551138, "CM3"),
    CM4(698.4564629, "CM4"),
    CM5(783.990872, "CM5"),
    CM6(880, "CM6"),
    CM7(987.7666025, "CM7"),
    CH1(1046.502261, "CH1"),
    CH2(1174.659072, "CH2"),
    CH3(1318.510228, "CH3"),
    CH4(1396.912926, "CH4"),
    CH5(1567.981744, "CH5"),
    CH6(1760, "CH6"),
    CH7(1975.533205, "CH7");

    private double freq;
    private String name;

    Freq(double freq, String name) {
        this.freq = freq;
        this.name = name;
    }

    public static Freq valueOf(double freq) {
        for (Freq v : Freq.values()) {
            if (v.freq == freq) {
                return v;
            }
        }
        throw new IllegalArgumentException();
    }

    public static Freq valueOfName(String name) {
        for (Freq v : Freq.values()) {
            if (v.name.equals(name)) {
                return v;
            }
        }
        throw new IllegalArgumentException();
    }

    public double getFreq() {
        return freq;
    }

    public String getName() {
        return name;
    }
}
